Repository navigation
Conversation
Contributor
Author
|
This PR only fixes a test scheduling race in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a scheduling race in
TestFTGenerators.test_concurrent_gi_frame(gh-161489).The test previously assumed the reader thread would observe the generator before the runner exhausted all 10,000 yields. Under
--parallel-threadsoversubscription the runner can finish first, leavingframesempty and causingAssertionError: 0 != 1even thoughgi_frameis correct.The test now uses two events to coordinate a first sample of a live generator after its first yield. The runner waits for that sample before advancing through the remaining values. Subsequent frame reads are still concurrent, and the existing
len(frames) == 1assertion remains unchanged: the test still detects unexpected frames or missing observations, rather than weakening the assertion to accept an unobserved run.Only the test file changes; no interpreter/runtime or public API modifications.
Verification
On a CPython
--with-pydebug --disable-gilbuild in my fork:--parallel-threads=4 -j4 -m test_concurrent_gi_frame: passed.test_free_threading.test_generatorsmodule: passed (7 tests).Run (free-threaded job): https://github.com/localzet/cpython/actions/runs/42410734206
The initial research workflow also attempted the module under a regular GIL build, where
test.test_free_threadingintentionally raisesSkipTestwhen imported directly byunittest. I've removed that inapplicable job from the follow-up workflow and the free-threaded rerun is underway.This is a tests-only PR, so
skip newsis appropriate (a maintainer may need to apply it).